<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Math对象</title>
</head>
<body>
    <h3>Math是JavaScript 的原生对象，提供各种数学功能</h3>

    <script>
        //1.Math.abs()
        //返回参数值的绝对值
        var num = -100;
        console.log(num);//-100
        console.log(Math.abs(num));//100

        //2.Math.max()     Math.min
        //Math.max():返回参数之中最大的那个值   Math.min()相反
        console.log(Math.max(10,-1,9,5,3));//10
        console.log(Math.min(10,-1,9,5,3));//-1
        
        //3.Math.floor()   Math.ceil()
        //Math.floor():向下取整     Math.ceil():向上取整
        console.log(Math.floor(3.2));//3
        console.log(Math.ceil(3.2));//4
        console.log(Math.floor(-3.2));//-4
        console.log(Math.ceil(-3.2));//-3
    
        //4.Math.random()
        //返回0~1的随机值，可能等于0,但一定小于1
        console.log(Math.random());//答案不唯一  范围:[0,1)
        
        //求一个范围内的随机数  如:6~15
        function  Rand(min,max){
            return Math.random() * (max-min) + min;
        }
        var ret = Rand(6,15);
        console.log(ret);
        
    </script>
</body>
</html>